package com.lupan.mutithred.cp4_Executor;

import java.util.Date;
import java.util.concurrent.ThreadFactory;

/**
 * 说明：
 *
 * @author lupan
 * @version 2017/4/26 14:26
 */
public class MyThreadFactory implements ThreadFactory {
    @Override
    public Thread newThread(Runnable r) {
        Thread thread = new Thread(r);
        thread.setName("自定义线程名_"+new Date());
        thread.setUncaughtExceptionHandler((t, e) -> System.out.println("进入自定义线程异常处理器。。。线程名:"+t.getName()+"线程异常："+e.getMessage()));
        return thread;
    }
}
